﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using ZX.CRM.Bussiness;
using System.Data;

namespace ZX.WebApp.Crm.Report
{
    public partial class RptPersonRanking : BasePage
    {
        BCrmReport bll = new BCrmReport();
        string startDate = string.Empty, endDate = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            startDate = this.GetStringFromQueryString("startDate", "");
            endDate = this.GetStringFromQueryString("endDate", "");
            if (!this.IsPostBack)
            {
                DataBind(startDate, endDate, "");
            }
            else
            {
                this.gvDataInfo.DataSource = this.Session["PersonData"];
                this.gvDataInfo.DataBind();
            }
        }
        private void DataBind(string startDate, string endDate, string deptName)
        {
            DataTable dt = bll.ReturnAllPersonBackMoneyRankReport(startDate, endDate, deptName);
            this.Session["PersonData"] = dt;
            this.gvDataInfo.DataSource = dt;
            this.gvDataInfo.DataBind();
        }
        /// <summary>
        /// 查询按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strDeptName = this.txtName.Value.Trim();
            if (strDeptName == "输入团队名或负责人查询...")
                strDeptName = "";
            DataBind(startDate, endDate, strDeptName);
        }
    }
}